﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ARSys.Entity;

namespace Wicresoft.Task.ARNotice.Emails
{
    class ShutdownNotify : EmailTemplate
    {
        public ShutdownNotify(Email armail, ARSysContext dc, params object[] entities)
            : base(armail, dc, entities)
        {

        }


        public override string[] To
        {
            get
            {
                //TO给owner
                return TryGetReceptions(armail.VMOwner);
            }
        }

        public override string[] Cc
        {
            get
            {
                //CC给虚拟化管理员
                var sql = from people in dc.People
                          from role in dc.Groups
                          from pg in dc.PGAssociations
                          where people.PeopleId == pg.PeopleId
                          where role.GroupId == pg.GroupId
                          where role.Name == "vApp Admin"
                          select people.Email;

                return sql.ToArray();
            }
        }
    }
}
